<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>制作出库单</title>
  <link href="../../css/style.css" rel="stylesheet" type="text/css">
  <script src="../../layui-v2.5.5/layui/layui.all.js"></script>
  <script src="../../layui-v2.5.5/layui/css/layui.css"></script>
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<center>
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="25" align="center" valign="bottom" class="td06"><table width="98%" border="0" cellspacing="3" cellpadding="0">
        <tr>
          <td width="15"><img src="../../images/index_32.gif" width="9" height="9"></td>
          <td valign="bottom" class="title">制作出库单</td>
        </tr>
      </table></td>
    </tr>
  </table>
  <form name="form1" method="post" action="" id="form1">
    <table width="95%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="90" height="24" class="td_form01">出库单填写人</td>
        <td class="td_form02">
          <input type="text" size="10">
        </td>
        <td width="90" class="td_form01">性别</td>
        <td class="td_form02">
          <select class="">
            <option>男</option>
            <option>女</option>
          </select>
        </td>
      </tr>
      <tr>

        <td class="td_form01">工号</td>
        <td class="td_form02">
          <input type="input" class="" size="10" name="outwarehouse.staid">
        </td>
        <td class="td_form01">出库日期</td>
        <td class="td_form02">
          <input type="date" class="" size="10" name="outwarehouse.outdate">
        </td>
      </tr>
    </table>
    <hr>
    <table width="600" size="1" class="table02">

      <tr>
        <td class="td_form01">药品编号</td>

        <td class="td_form01">出库数量</td>

        <td class="td_form01">出库日期</td>

        <td class="td_form01">操作</td>
      </tr>

      <tr>
        <td class="td_form02">
          <input type="text" size="5" class="drugid" name="outdrug[0].drugid">
        </td>

        <td class="td_form02">
          <input type="text" size="5" class="drugnumber" name="outdrug[0].outdnum">
        </td>

        <td class="td_form02">
          <input type="date" class="frmcheckdate" name="outdrug[0].outddate" >
        </td>

        <td class="td_form02">
          <input type="button" class="add" value="添加" onclick='add()'>
          <input type="button" class="del" value="删除" onclick="del(this)">
        </td>
      </tr>
    </table>
    <br>
    <table width=95% border=0 align=center cellpadding=0 cellspacing=0 whdth='100%'>
      <tr>
        <td align="center">

          <input name=save  type='button' class="sub" value= '  提交  '  >
          <input name=cancel  type=button class="return" value= '  返回  ' ></td>
      </tr>
    </table>
  </form>
</center>
</body>
</html>
<script src="../../js/jquery.js">

</script>
<script>


  var i=0;
  //添加一行
  function add() {
    // alert("添加")
    i=$(".add").length;
    console.log(i)
    var _tr =" <tr>\n" +
            "          <td class=\"td_form02\">\n" +
            "            <input type=\"text\" size=\"5\" class=\"drugname\" name=\"outdrug["+i+"].drugid\">\n" +
            "          </td>\n" +
            "\n" +
            "          <td class=\"td_form02\">\n" +
            "            <input type=\"text\" size=\"5\" class=\"drugnumber\" name=\"outdrug["+i+"].outdnum\">\n" +
            "          </td>\n" +
            "\n" +
            "          <td class=\"td_form02\">\n" +
            "            <input type=\"date\" class=\"frmcheckdate\" name=\"outdrug["+i+"].outddate\" >\n" +
            "          </td>\n" +
            "\n" +
            "          <td class=\"td_form02\">\n" +
            "            <input type=\"button\" class=\"add\" value=\"添加\" onclick='add()'>\n" +
            "            <input type=\"button\" class=\"del\" value=\"删除\" onclick=\"del(this)\">\n" +
            "          </td>\n" +
            "        </tr>"
    $(".table02").append(_tr);



  }
  //删除一行
  function del($this) {
    // alert("删除")

    $($this).parent().parent().remove();
  }

  $(".sub").on("click",function () {

    $.ajax({
      url:"/feign/drugStorageController/addOutWInfo",
      data:$("#form1").serialize(),
      type:"post",
      headers: {
        Accept: "application/json; charset=utf-8",
        Authorization: location.href.split("=")[1]
      },
      dataType:"text",
      success:function (data) {
        console.log(data);
        if(data=="fail"){
          layer.msg("添加失败，重新输入")
        }else{
          layer.msg("添加成功")
        }
      },

    });

  })
</script>
